package lib;

/**
 * Support class for the GUI to display the books in the search result.
 * @author smy
 */
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;

public class Book implements Serializable{
	private static final long serialVersionUID = 9133727010546468195L;
	private int no;
	private String title;
	private String author;
	private String publisher;
	private String reqid;
	private String type;
	private String marc_no;
	private ArrayList<String> locations = new ArrayList<String>();
	private ArrayList<String> availability = new ArrayList<String>();
	private Date lastupdated;
/**
 * Constructor; used to create a book instance.
 * @param num: No.
 * @param a Book's title
 * @param b Book's author
 * @param c Book's publisher
 * @param d Book's request ID
 * @param e Book's type
 * @param f Book's marc_no (not useful outside the code)
 */
	protected Book(int num, String a, String b, String c, String d, String e,
			String f) {
		this.no = num;
		this.title = a;
		this.author = b;
		this.publisher = c;
		this.reqid = d;
		this.type = e;
		this.marc_no = f;
		this.lastupdated=new Date();
	}

	public String toString() {
		return no + " " + title + " " + author + " " + publisher + " " + reqid
				+ " " + type+" "+lastupdated;
	}

	public String getmarcno() {
		return marc_no;
	}

	protected void setlocation(String str) {
		this.locations.add(str);
	}

	protected void setavailability(String str) {
		this.availability.add(str);
	}
    protected void clear(){
    	this.locations.clear();
    	this.availability.clear();
    }
    public long getlastupdated(){
    	return lastupdated.getTime();
    }
    protected void update(){
    	this.lastupdated=new Date();
    }
}
